home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-3484
/
spufile
/
spufile.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-01-27
|
21KB
|
959 lines
/*************************************************************
Spufile 1.0
by
Gregory Mathias Lemperle-Kerr
***************************************************************
Synopsis:
This program will list the files on a mac
400/800/360/720K disk with the old mac
file system.
It can be used with MagicSac and/or Aladin/
SPUMAC 1 & 2 sided disks as well as Spectre 128
1 sided disks.
It is written to be a subroutine of SPUMACST.
It will then transfer a specified file from
the Mac type disk to a gem format diskette
in the form of file.mac, file.mrs and file.inf
(the data, resource & informative parts of the
file respectively).
The .INF file is necessary for proper return
of the file to a mac type disk.
**********************************************************************/
#include <stdio.h>
#include <osbind.h>
#define unt unsigned int
#define MACINF 0x0
#define MACDAT 0x1
#define MACRSC 0x2
#define READ 0x0
#define WRITE 0x1
#define RW 0x2
int rderr;
unt sec[256],
fat[512],
blk,
j,
i,
n,
fn,
disktype,
odsktype;
long bytesperdisk,
stflbk;
char s,
t,
sd,
k,
m,
*fbuf[2048];
struct STdisk
{
long free;
long total;
long bps;
long spc;
}
stdisk;
struct STfile
{
char name[44];
long bytes;
}
stdata[256],
strsrc[256],
stinfo[256];
struct appledisk
{
unt hfs;
long initdate;
long backdate;
unt attrib;
unt files;
unt directory;
unt dirlen;
unt blocks;
long bpblk;
long bytesperalo;
unt firstblock;
long filenum;
unt freeblocks;
char namelen;
char name[26];
char spt;
char firsttrack;
char sides;
char spb;
}
macdisk,omacdsk;
struct applefile
{
unt attrib; /* char attrib + char version */
long findera;
long finderb;
long finderc;
long finderd;
long filenum;
unt datastart;
long dataleof;
long datapeof;
unt rscstart;
long rscleof;
long rscpeof;
long create;
long lastmod;
char namelen;
char name[66];
}
macfile[256],
definfo;
memfree()
{
unt f=0;
while (fbuf[f]) Mfree (fbuf[f++]);
}
leave()
{
memfree();
printf("\n\nPress RETURN to exit:");
fgetc(stdin);
exit();
}
errunkn(ek)
char ek;
{
printf("\n%c%c%c Error number: %d !",0x7,0x7,0x7,ek);
leave();
}
memallo(z,amt)
unt z;
long amt;
{
if ( ( fbuf[z] = ( (char *) Malloc(amt) ) ) <= 0 ) errunkn(15);
}
readsec(sector,track,side,buf)
unt sector;
unt track;
unt side;
char *buf;
{
if (rderr = Floprd(buf,0L,0,sector,track,side,1) != 0)
{
printf("\n Read error (%x) on side %d, track %d, sec %d!\n"
,rderr,side,track,sector);
leave();
}
}
writsec(sector,track,side,buf)
unt sector;
unt track;
unt side;
char *buf;
{
if (rderr = Flopwr(buf,0L,0,sector,track,side,1) != 0)
{
printf("\n Write error (%x) on side %d, track %d, sec %d!\n"
,rderr,side,track,sector);
leave();
}
}
dumpbuf(buf,bytes)
unt buf;
unt bytes;
{
char c;
unt x;
printf(" >>> First %x bytes:",bytes);
for (x = 0 ; x < bytes ; x++)
{
c = *(fbuf[buf]+x);
if ( ( (c < 'A') || (c > 'Z') ) && ( (c < 'a') || (c > 'z') )
&&( (c < '0') || (c > '9') ) )
c = '_';
printf("%c",c);
}
printf("\015");
}
setMCnm(fname, type)
char *fname;
char type;
{
unt pos;
int filedes;
char c;
*(fname) = 'A';
*(fname+1) = ':';
for ( pos=0 ; (pos < 8) && ( macfile[fn].name[pos] ) ; pos++ )
{
c = macfile[fn].name[pos];
if ( ( (c < 'A') || (c > 'Z') ) && ( (c < 'a') || (c > 'z') )
&&( (c < '0') || (c > '9') ) )
c = '_';
*(fname+pos+2) = c;
}
*(fname+pos+2)='.';
switch (type)
{
case MACDAT:
*(fname+pos+3)='M';
*(fname+pos+4)='A';
*(fname+pos+5)='C';
break;
case MACRSC:
*(fname+pos+3)='M';
*(fname+pos+4)='R';
*(fname+pos+5)='S';
break;
default:
*(fname+pos+3)='I';
*(fname+pos+4)='N';
*(fname+pos+5)='F';
break;
}
*(fname+pos+6)=0x0;
printf("\n Wrote: %s - ",fname);
if ( Fsfirst(fname,0) >= 0 )
putover(fname);
filedes=Fcreate(fname,0x0);
if ( !filedes ) errunkn(21);
Fclose(filedes);
if ( filedes = Fopen(fname,WRITE) )
return(filedes);
errunkn(49);
}
setMCds()
{
if (sec[0] == 0xd2d7)
{
macdisk.hfs = sec[0];
macdisk.initdate = sec[1] * 0x10000 + sec[2];
macdisk.backdate = sec[3] * 0x10000 + sec[4];
macdisk.attrib = sec[5];
macdisk.files = sec[6];
macdisk.directory = sec[7];
macdisk.dirlen = sec[8];
macdisk.blocks = sec[9];
macdisk.bpblk = sec[10] * 0x10000 + sec[11];
macdisk.bytesperalo = sec[12] * 0x10000 + sec[13];
macdisk.firstblock = sec[14];
macdisk.filenum = sec[15] * 0x10000 + sec[16];
macdisk.freeblocks = sec[17];
macdisk.namelen = sec[18] / 0x100;
macdisk.spb = macdisk.bpblk / 0x200;
for (i=0,j=0;i<macdisk.namelen;i++,j=j+2)
{
macdisk.name[j] =sec[18+i];
macdisk.name[j+1] =sec[18+i+1]/0x100;
}
macdisk.name[25]=macdisk.name[26]=0;
if (macdisk.namelen<24)
macdisk.name[macdisk.namelen]=macdisk.name[macdisk.namelen+1]=0;
bytesperdisk = macdisk.firstblock * 0x200 + macdisk.blocks * macdisk.bpblk;
}
else macdisk.hfs = 0;
}
gettype()
{
disktype = 0;
readsec(0x03,0x00,0x00,sec);
if (sec[0] != 0xd2d7) Dfree(&stdisk,1);
setMCds();
if (macdisk.hfs == 0xd2d7)
{
macdisk.sides=0;
macdisk.spt=10;
macdisk.firsttrack=0;
if (bytesperdisk > 0x64000)
{
disktype = 4;
macdisk.sides = 1;
}
else disktype = 2;
}
else
{
readsec(0x0003,0x0001,0x0000,&sec[0]);
setMCds();
if (macdisk.hfs == 0xd2d7)
{
macdisk.spt =9 ;
macdisk.firsttrack = 1;
macdisk.sides = 0;
if (bytesperdisk > 0x58e00)
{
disktype = 3;
macdisk.sides = 1;
}
else disktype = 1;
}
}
if ( disktype ) getMCft();
else Dfree(&stdisk,1);
}
outtype()
{
printf("\n\n Type: %d - ",disktype);
switch (disktype)
{
case 0x1:
printf("SPUMAC / Aladin 1 side");
break;
case 0x2:
printf("MagicSac 1 side");
break;
case 0x3:
printf("SPUMAC / Aladin 2 sides");
break;
case 0x4:
printf("MagicSac 2 sides");
break;
default:
printf("GEM / PC");
break;
}
if (disktype)
{
printf(" Title: %s",macdisk.name);
printf("\n Initialize Date:$%lx",macdisk.initdate);
printf("\n Backup Date :$%lx",macdisk.backdate);
printf("\n Name Length : %d",macdisk.namelen);
printf("\n Directory Start: %d",macdisk.directory);
printf("\n Directory Secs : %d",macdisk.dirlen);
printf("\n Attributes :$%x",macdisk.attrib);
printf("\n Next Filenumber: %ld",macdisk.filenum);
printf("\n Number of files: %d",macdisk.files);
printf("\n First block : %d",macdisk.firstblock);
printf("\n Total blocks : %d",macdisk.blocks);
printf("\n Free blocks : %d",macdisk.freeblocks);
printf("\n Bytes per block: %ld",macdisk.bpblk);
printf("\n Secs per block : %d",macdisk.spb);
printf("\n Bytes per alloc: %ld",macdisk.bytesperalo);
printf("\n Bytes per disk : %ld",bytesperdisk);
}
else
{
printf("\n Total CLUS:%ld",stdisk.total);
printf("\n Free CLUS:%ld",stdisk.free);
printf("\n Sec / CLUS:%ld",stdisk.spc);
printf("\n Byte / Sec:%ld\n",stdisk.bps);
printf("\n Free Space:%ld\n\n",stdisk.free * stdisk.bps * stdisk.spc);
}
}
setMCin()
{
sec[0] = macfile[fn].attrib;
sec[1] = macfile[fn].findera / 0x10000;
sec[2] = macfile[fn].findera;
sec[3] = macfile[fn].finderb / 0x10000;
sec[4] = macfile[fn].finderb;
sec[5] = macfile[fn].finderc / 0x10000;
sec[6] = macfile[fn].finderc;
sec[7] = macfile[fn].finderd / 0x10000;
sec[8] = macfile[fn].finderd;
sec[9] = macfile[fn].create / 0x10000;
sec[10] = macfile[fn].create;
sec[11] = macfile[fn].lastmod / 0x10000;
sec[12] = macfile[fn].lastmod;
sec[13] = macfile[fn].namelen * 0x100 + macfile[fn].name[0];
for (k=m=1;(k<64) && (k<macfile[fn].namelen);k++,m=m+2)
sec[13+k] = macfile[fn].name[m+1] + (macfile[fn].name[m] * 0x100);
for (m=k ; m < 64 ; m++) sec[13+m]=0;
}
setMCdr()
{
macfile[j].attrib =sec[n+0];
macfile[j].findera =sec[n+1]*0x10000L+sec[n+2];
macfile[j].finderb =sec[n+3]*0x10000L+sec[n+4];
macfile[j].finderc =sec[n+5]*0x10000L+sec[n+6];
macfile[j].finderd =sec[n+7]*0x10000L+sec[n+8];
macfile[j].filenum =sec[n+9]*0x10000L+sec[n+10];
macfile[j].datastart =sec[n+11];
macfile[j].dataleof =sec[n+12]*0x10000L+sec[n+13];
macfile[j].datapeof =sec[n+14]*0x10000L+sec[n+15];
macfile[j].rscstart =sec[n+16];
macfile[j].rscleof =sec[n+17]*0x10000L+sec[n+18];
macfile[j].rscpeof =sec[n+19]*0x10000L+sec[n+20];
macfile[j].create =sec[n+21]*0x10000L+sec[n+22];
macfile[j].lastmod =sec[n+23]*0x10000L+sec[n+24];
macfile[j].namelen =sec[n+25]/0x100;
for (k=m=0;(k<64) && (k<macfile[j].namelen);k++,m=m+2)
{
macfile[j].name[m] =sec[n+25+k];
macfile[j].name[m+1] =sec[n+25+k+1]/0x100;
}
macfile[j].name[macfile[j].namelen]=macfile[j].name[macfile[j].namelen+1]=0;
n=n+25+macfile[j].namelen/2;
}
getMCdr()
{
j = sd = 0;
s = macdisk.directory;
s++;
t = macdisk.firsttrack;
for ( i = 0 , sec[0] = 0x8000; (sec[0] == 0x8000) && (i <= 255) ; i++ )
{
readsec(s,t,sd,&sec[0]);
n = 0;
while (n <= 255)
{
if (sec[n] == 0x8000)
{
setMCdr();
macfile[++j].attrib=0;
}
++n;
}
if (++s > macdisk.spt)
{
s=1;
if (macdisk.sides == 0)
++t;
else if ((sd = 1 - sd) == 0)
++t;
}
}
}
setMCft()
{
fat[j+0] = (sec[i+0]/0x10);
fat[j+1] = ((sec[i+0]&0x000F)*0x100)+(sec[i+1]/0x100 );
fat[j+2] = ((sec[i+1]&0x00FF)*0x10 )+(sec[i+2]/0x1000);
fat[j+3] = (sec[i+2]&0x0FFF);
}
getMCft()
{
readsec(0x0003,macdisk.firsttrack,0x0000,&sec[0]);
for (i = 32, j = 0; j < 296; i = i + 3, j = j + 4) setMCft();
fat[296] = (sec[254]/0x10);
fat[297] = ((sec[254]&0x000F)*0x100)+(sec[255]/0x100);
fat[298] = (sec[255]&0x00ff)*0x10;
readsec(0x0004,macdisk.firsttrack,0x0000,&sec[0]);
for ( i = 1 , j = 300 ; j < 509 ; i = i + 3 , j = j + 4 ) setMCft();
fat[298] = fat[298]+(sec[0]/0x1000);
fat[299] = sec[0]&0x0fff;
}
setMCbk(b, sc, tk, sd)
unt b,
*sc,
*tk,
*sd;
{
*sd = 0;
*tk = macdisk.firsttrack;
for ( *sc = (b - 2) * macdisk.spb + macdisk.firstblock + 1;
*sc > macdisk.spt ; *sc = ( *sc - macdisk.spt) )
{
if (macdisk.sides == 0)
++*tk;
else if (( *sd = (1 - *sd)) == 0)
++*tk;
}
}
gptMCbk(rw, b, z)
char rw;
unt b,
z;
{
unt sector,
track,
side,
count;
char *fb;
setMCbk(b, §or, &track, &side);
memallo(z,macdisk.bpblk);
fb = fbuf[z];
for ( count = 0 ; count < macdisk.spb ; count++ )
{
if ( rw ) writsec(sector,track,side,fb);
else readsec(sector,track,side,fb);
fb = fb + 0x200;
if ((++sector) > macdisk.spt)
{
sector = 1;
if (macdisk.sides == 0)
++track;
else if ((side = (1 - side)) == 0)
++track;
}
}
}
putMCdt()
{
}
putMCrs()
{
}
putMCin()
{
}
getMCdt()
{
unt z;
unt current;
current = macfile[fn].datastart;
for (z = blk; (z-blk) < (macfile[fn].datapeof / macdisk.bpblk); z++)
{
printf(" Reading data block %4x: %4x",z,current);
gptMCbk(READ,current,z);
dumpbuf(z,20);
current = fat[current - 2 ];
}
blk = z;
}
getMCrs()
{
unt z;
unt current;
current = macfile[fn].rscstart;
for (z = blk; (z-blk) < (macfile[fn].rscpeof / macdisk.bpblk); z++)
{
printf(" Reading rsrc block %4x: %4x\n",z,current);
gptMCbk(READ,current,z);
current = fat[current - 2 ];
}
blk = z;
}
putSTdt(fd)
int fd;
{
unt z;
long last;
last = 0;
for (z = blk; (z-blk + 1) < (macfile[fn].datapeof / omacdsk.bpblk); z++)
{
printf("%4x ",z);
if (!Fwrite(fd,omacdsk.bpblk,fbuf[z])) errunkn(3);
last = last + omacdsk.bpblk;
}
printf("%4x ",z);
if (!Fwrite(fd,macfile[fn].dataleof-last,fbuf[z++])) errunkn(4);
blk = z;
}
putSTrs(fd)
int fd;
{
unt z;
long last;
last = 0;
for (z = blk; (z-blk + 1) < (macfile[fn].rscpeof / omacdsk.bpblk); z++)
{
printf("%4x ",z);
if (!Fwrite(fd,omacdsk.bpblk,fbuf[z])) errunkn(6);
last = last + omacdsk.bpblk;
}
printf("%4x ",z);
if (!Fwrite(fd,macfile[fn].rscleof-last,fbuf[z++])) errunkn(5);
blk = z;
}
setSTdr(path,dta)
char *path;
char *dta;
{
unt y,
z;
stdata[fn].bytes = *( (long *)(dta + 26) );
for ( y=0 ; ( stdata[fn].name[y] = *(path + y) ) ; y++ );
y = y - 3;
for ( z = y ; z < ( y + 14 ) ; z++ )
stdata[fn].name[z] = *(dta + z - y + 30);
stdata[fn].name[z] = 0;
stdata[++fn].name[0] = 0;
}
getSTdr()
{
char drive[32];
drive[0] = 'A';
drive[1] = ':';
drive[2] = 0x5c;
drive[3] = 0x2a;
drive[4] = '.';
drive[5] = 0x2a;
drive[6] = 0x0;
getSTpt(&drive[0]);
}
getSTpt(path)
char *path;
{
int new;
unt z,
deep=0,
p;
char *dta,
temp[32];
printf("Searching: %-44s\n",path);
if (Fsfirst(path,0) >=0 ) setSTdr( path, (char *)Fgetdta() );
while ( Fsnext() >= 0 ) setSTdr ( path, (char *)Fgetdta() );
new = Fsfirst(path,0x10);
dta = (char *)Fgetdta();
while ( ( ( *(dta+30) == 0x2e ) || ( *(dta+21) != 0x10 ) )
&& ( ( new = Fsnext() ) >= 0 ) )
dta = ( (char *)Fgetdta() );
while (new >= 0)
{
for( p = 0 ; p < 32 ; p++) temp[p]=*(path+p);
for ( p = 0 ; temp[p] ; p++);
p = p - 3;
for ( z = p ; ( (z-p) < 14) && ( temp[z] = *(dta+z-p+30) ) ; z++ );
temp[z ] = 0x5c;
temp[z+1] = 0x2a;
temp[z+2] = '.';
temp[z+3] = 0x2a;
temp[z+4] = 0x0;
getSTpt(&temp[0]);
new = Fsfirst(path,0x10);
dta = (char *)Fgetdta();
while ( ( ( *(dta+30) == 0x2e ) || ( *(dta+21) != 0x10 ) )
&& ( ( new = Fsnext() ) >= 0 ) )
dta = ( (char *)Fgetdta() );
++deep;
for(z = deep ; z && (new >= 0) ; z--)
{
new = Fsnext();
dta = (char *)Fgetdta();
if ( (new >= 0) && ( *(dta+21) != 0x10 ) ) z++;
}
}
}
outSTdr()
{
char pos;
printf("\n\n Press RETURN to see file listing of %d files:",fn);
fgetc(stdin);
printf("\n\nChoice Pathname Length");
printf( "\n------ ---------------------------------------- ------");
for (i=0;stdata[i].name[0];i++)
printf("\n%-7d%-44s%6ld",i,((&stdata[i])->name) + 2,stdata[i].bytes);
printf( "\n------ ---------------------------------------- ------\n");
}
choSTfl()
{
long freemem;
unt f;
char *stf;
outSTdr();
freemem = Malloc(-1L);
printf("Free Memory:%ld bytes, Transfer:",freemem);
scanf("%d",&f);
getc(stdin);
if (f > fn)
{
printf("\nNot a valid choice!%c",7);
leave();
}
fn = f;
stf = ( (&stdata[fn])->name );
for ( f = 0 ; (f < 44) && *(stf + f) ; f++ )
stinfo[fn].name[f] = ( strsrc[fn].name[f] = *(stf + f) );
f = f - 3;
stinfo[fn].name[f ] = 'I';
stinfo[fn].name[f+1] = 'N';
stinfo[fn].name[f+2] = 'F';
strsrc[fn].name[f ] = 'R';
strsrc[fn].name[f+1] = 'S';
strsrc[fn].name[f+2] = 'C';
strsrc[fn].bytes = 0x0L;
stinfo[fn].bytes = 0x0L;
if ( ( ( *(stf+f) != 'R' ) || ( *(stf+f+1) != 'S' ) || ( *(stf+f+2) != 'C' ) )
&& ( Fsfirst( (&strsrc[fn])->name, 0 ) >= 0 ) )
{
stf = (char *)Fgetdta();
strsrc[fn].bytes = *((long *)(stf + 26));
}
if ( ( ( *(stf+f) != 'I' ) || ( *(stf+f+1) != 'N' ) || ( *(stf+f+2) != 'F' ) )
&& ( Fsfirst( (&stinfo[fn])->name, 0 ) >= 0 ) )
{
stf = (char *)Fgetdta();
stinfo[fn].bytes = *((long *)(stf + 26));
}
if (freemem < ( stdata[fn].bytes + strsrc[fn].bytes +stinfo[fn].bytes ) )
{
printf("\nNot enough memory for that file!%c",7);
leave();
}
}
getSTfl()
{
unt z;
getSTdr();
choSTfl();
getSTst( (&stdata[fn])->name, stdata[fn].bytes );
if ( strsrc[fn].bytes ) getSTst( (&strsrc[fn])->name, strsrc[fn].bytes);
if ( stinfo[fn].bytes ) getSTst( (&stinfo[fn])->name, stinfo[fn].bytes);
}
getSTst(stf, length)
char *stf;
long length;
{
int fd;
unt z;
long crap;
if (Fsfirst(stf,0) < 0 )
{
printf("File %s was not found!%c",stf,0x7);
leave();
}
crap = Fgetdta();
if ( ( fd = Fopen(stf,READ) ) < 0 ) errunkn(37);
printf("Reading: %s\n",stf);
for ( z=blk ; (z - blk + 1) < (length / 0x200L ) ; z++ )
{
memallo(z,0x200L);
Fread(fd,0x200L,fbuf[z]);
}
memallo(z,0x200L);
Fread(fd,(length - ( (z - blk + 1) * 0x200L) ), fbuf[z++]);
blk = z;
Fclose(fd);
}
putSTst(stf,length)
char *stf;
long length;
{
int fd;
unt z;
printf("Writing: %s\n",stf);
if (Fsfirst(stf,0) >= 0 ) putover(stf);
if ( ( fd = Fcreate(stf,0) ) < 0 ) errunkn(39);
Fclose(fd);
if ( ( fd = Fopen(stf,WRITE) ) < 0 ) errunkn(31);
for ( z=blk ; (z - blk + 1) < (length / 0x200 ) ; z++ )
Fwrite(fd,0x200L,fbuf[z]);
Fwrite(fd,(length - ( (z - blk + 1) * 0x200L) ), fbuf[z++]);
blk = z;
Fclose(fd);
}
putSTfl()
{
long dblk,
iblk,
rblk,
STbpc;
int filedes;
char stfname[44],
*inb;
Dfree(&stdisk,1);
STbpc= stdisk.bps * stdisk.spc;
iblk = (odsktype > 0);
dblk = (iblk * macfile[fn].datapeof / STbpc )
+ ((1-iblk) * stflbk);
rblk = iblk * macfile[fn].rscpeof / STbpc;
printf("\n CLUSTERS- Free:%ld > Need: Data:%ld, Resource:%ld, Info:%ld.\n",
stdisk.free,dblk,rblk,iblk);
if ( stdisk.free < (dblk + iblk + rblk))
{
printf("Not enough space!");
leave();
}
else
{
if (!iblk)
{
putSTst( (&stdata[fn])->name );
if ( strsrc[fn].bytes ) putSTst( (&strsrc[fn])->name, strsrc[fn].bytes );
if ( strsrc[fn].bytes ) putSTst( (&stinfo[fn])->name, stinfo[fn].bytes );
}
else
{
filedes = setMCnm(&stfname[0],MACINF);
setMCin();
if (!Fwrite(filedes,0x50L,&sec[0])) errunkn(2);
if (Fclose(filedes) < 0) errunkn(1);
if (macfile[fn].dataleof)
{
filedes = setMCnm(&stfname[0],MACDAT);
putSTdt(filedes);
if (Fclose(filedes) < 0) errunkn(1);
}
if (macfile[fn].rscleof)
{
filedes = setMCnm(&stfname[0],MACRSC);
putSTrs(filedes);
if (Fclose(filedes) < 0) errunkn(1);
}
}
}
}
putover(fname)
char *fname;
{
char response;
printf("\n Do you wish to overwrite %s y/n:",fname);
scanf("%c",&response);
fgetc(stdin);
if ( ( response='n' ) || ( Fdelete(fname) < 0x0) )
{
printf("\n Error deleting old file!%c",0x7);
leave();
}
}
getfile()
{
if ( disktype )
{
getMCdr();
choMCfl();
if ( macfile[fn].datastart ) getMCdt();
if ( macfile[fn].rscstart ) getMCrs();
}
else getSTfl();
}
putfile()
{
if ( disktype )
{
if ( macfile[fn].datastart ) putMCdt();
if ( macfile[fn].rscstart ) putMCrs();
putMCin();
}
else putSTfl();
}
outMCdr()
{
char fname[9],
pos;
fname[8] = 0;
printf("\n\n Press RETURN to see file listing:");
fgetc(stdin);
printf("\n\nChoice Filename DatLen DatUse RscLen RscUse MemUse");
printf( "\n------ -------- ------ ------ ------ ------ ------\n");
for (i=0;((macfile[i].attrib == 0x8000) && (i<=255));i++)
{
for(pos = 0; (pos < 8) && (macfile[i].name[pos]) ; pos++)
fname[pos]=macfile[i].name[pos];
fname[pos]=0;
printf("%-7d",i);
printf("%-8s",fname);
printf("%9ld%9ld%11ld%9ld%14ld\n",
macfile[i].dataleof,macfile[i].datapeof,
macfile[i].rscleof,macfile[i].rscpeof,
macfile[i].datapeof+macfile[i].rscpeof);
}
printf("------ -------- ------ ------ ------ ------ ------\n");
}
choMCfl()
{
long freemem;
outMCdr();
freemem = Malloc(-1L);
printf("Free Memory:%ld bytes, Transfer:",freemem);
scanf("%d",&fn);
getc(stdin);
if (fn > macdisk.files)
{
printf("\nNot a valid choice!%c",7);
leave();
}
if (freemem < (macfile[fn].datapeof + macfile[fn].rscpeof))
{
printf("\nNot enough memory for that file!%c",7);
leave();
}
}
main()
{
Dsetdrv(0x0);
printf(" SPUFILE 1.0 (GAMMA) by Gregory Mathias Lemperle-Kerr (C) 1989! Gem:%4x\n\n",
(Sversion()) );
printf("\n Insert source in A:\n\n Press RETURN when ready:");
fgetc(stdin);
gettype();
outtype();
blk = 0;
getfile();
odsktype = disktype;
omacdsk = macdisk;
printf("\n Insert destination in A:\n\n Press RETURN when ready:");
fgetc(stdin);
gettype();
outtype();
blk = 0;
putfile();
leave();
}